cmake_minimum_required(VERSION 3.10)
project(LogClient)


# 设置C++标准
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 指定Qt5路径为MSVC版本
set(Qt5_DIR "C:/Qt/5.15.2/msvc2019_64/lib/cmake/Qt5")

# 查找Qt库
find_package(Qt5 REQUIRED COMPONENTS Core WebSockets)

SET(AUTOMOC ON)
# 启用Qt的MOC
set(CMAKE_AUTOMOC ON)

# 添加源文件
set(SOURCES
    LogClient.cpp
)

# 添加头文件
set(HEADERS
    LogClient.h
)

# 创建库
add_library(LogClient STATIC ${SOURCES} ${HEADERS})

# 设置库的链接属性
set_target_properties(LogClient PROPERTIES
    POSITION_INDEPENDENT_CODE ON
)

# 包含目录
target_include_directories(LogClient PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
)

# 链接库
target_link_libraries(LogClient PUBLIC
    Qt5::Core
    Qt5::WebSockets
)

# 安装规则
install(TARGETS LogClient DESTINATION lib)
install(FILES ${HEADERS} DESTINATION include)

# 示例程序（可选）
option(BUILD_EXAMPLES "Build example programs" ON)

if(BUILD_EXAMPLES)
    # 添加示例目录
    add_subdirectory(examples)
endif()